package com.tianji.learning.controller;


import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 互动提问的问题表 前端控制器
 * </p>
 *
 * @author lyh
 * @since 2024-12-11
 */
@RestController
@RequestMapping("/questions")
@RequiredArgsConstructor
public class InteractionQuestionController {

    private final IInteractionQuestionService questionService;

    @ApiOperation("新增提问")
    @PostMapping
    public void saveQuestion(@RequestBody QuestionFormDTO questionDTO){
        questionService.saveQuestion(questionDTO);
    }

    @ApiOperation("分页查询互动问题")
    @GetMapping("/page")
    public PageDTO<QuestionVO> queryQuestionPage(QuestionPageQuery query){
        return questionService.queryQuestionPage(query);
    }
    @GetMapping("/{id}")
    @ApiOperation("根据id查询问题详情")
    public QuestionVO getQuestionById(@PathVariable("id") Long id){
        return questionService.getQuestionById(id);
    }
    @PutMapping("/{id}")
    @ApiOperation("修改问题")
    public void updateQuestion(@RequestBody QuestionFormDTO dto,@PathVariable Long id){
        questionService.updateQuestion(dto,id);
    }
    @DeleteMapping("/{id}")
    @ApiOperation("删除问题")
    public void deleteQuestion(@PathVariable Long id){
      questionService.deleteQuestion(id);
    }

}